home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / info-service / gopher / Rice_CMS / gopher24 / gopsrvmb.$rexx < prev    next >
Encoding:
Text File  |  1993-01-25  |  17.2 KB  |  218 lines

  1. /*                                                                      00010000
  2.  *        Name: GOPSRVMB REXX                                           00020000
  3.  *              CMS Gopher Server menu builder pipeline stage           00030000
  4.  *              Based on the older GOPHERDM REXX stage from 2.3.        00040000
  5.  *      Author: Rick Troth, Rice University, Information Systems        00050000
  6.  *        Date: 1993-Jan-15                                             00060000
  7.  */                                                                     00070000
  8.                                                                         00080000
  9. /*                                                                      00090000
  10.  *      Copyright 1993 Richard M. Troth.   This software was developed  00100000
  11.  *      with resources provided by Rice University and is intended      00110000
  12.  *      to serve Rice's user community.   Rice has benefitted greatly   00120000
  13.  *      from the free distribution of software,  therefore distribution 00130000
  14.  *      of unmodified copies of this material is not restricted.        00140000
  15.  *      You may change your own copy as needed.   Neither Rice          00150000
  16.  *      University nor any of its employees or students shall be held   00160000
  17.  *      liable for damages resulting from the use of this software.     00170000
  18.  */                                                                     00180000
  19.                                                                         00190000
  20. uc = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"                                       00200000
  21. lc = "abcdefghijklmnopqrstuvwxyz"                                       00210000
  22.                                                                         00220000
  23. /*  sync with input  */                                                 00230000
  24. 'PEEKTO'                                                                00240000
  25. If rc ^= 0 Then Exit rc * (rc ^= 12)                                    00250000
  26.                                                                         00260000
  27. /*  experience shows that sometimes GLOBALV SELECT        *             00270000
  28.  *  doesn't work unless you explicitly sync with PEEKTO   */            00280000
  29. Address "COMMAND" 'GLOBALV SELECT GOPHERD GET HOST PORT PATH MENU'      00290000
  30. localhost = host                                                        00300000
  31. localport = port                                                        00310000
  32. localpath = path                                                        00320000
  33. Say "Global PATH =" path                                                00330000
  34.                                                                         00340000
  35. Do Forever                                                              00350000
  36.                                                                         00360000
  37.     'PEEKTO RECORD'                                                     00370000
  38.     If rc ^= 0 Then Leave                                               00380000
  39.                                                                         00390000
  40.     key = Left(record,1)                                                00400000
  41.     Select  /*  key  */                                                 00410000
  42.         When key = "*" Then nop                                         00420000
  43.         When Strip(record) = "" Then nop                                00430000
  44.         When key = " " Then Call FILELIST                               00440000
  45.         Otherwise           Call PREFAB                                 00450000
  46.         End  /*  Select  key  */                                        00460000
  47.     If rc ^= 0 Then Leave                                               00470000
  48.                                                                         00480000
  49.     'READTO'                                                            00490000
  50.     If rc ^= 0 Then Leave                                               00500000
  51.                                                                         00510000
  52.     End  /*  Do  For  */                                                00520000
  53.                                                                         00530000
  54. Exit rc * (rc ^= 12)                                                    00540000
  55.                                                                         00550000
  56.                                                                         00560000
  57.                                                                         00570000
  58. /* ------------------------------------------------------------ FILELIST00580000
  59.  *  We're apparently reading a plain FILELIST or LISTFILE output.       00590000
  60.  */                                                                     00600000
  61. FILELIST:                                                               00610000
  62.                                                                         00620000
  63. q1 = Index(record,"'")                                                  00630000
  64. q2 = Index(record,'"')                                                  00640000
  65. Select                                                                  00650000
  66.     When  q1 = 0  & q2 = 0  Then                                        00660000
  67.         Parse Var record fn ft fm fp '05'x name '05'x type '05'x .      00670000
  68.     When  q1 = 0  Then                                                  00680000
  69.         Parse Var record fn ft fm fp '"'name'"' type .                  00690000
  70.     When  q2 = 0  Then                                                  00700000
  71.         Parse Var record fn ft fm fp "'"name"'" type .                  00710000
  72.     When  q1 > q2 Then                                                  00720000
  73.         Parse Var record fn ft fm fp '"'name'"' type .                  00730000
  74.     When  q2 > 0  Then                                                  00740000
  75.         Parse Var record fn ft fm fp "'"name"'" type .                  00750000
  76.     End  /*  Select  */                                                 00760000
  77.                                                                         00770000
  78. If ft = "" Then ft = "*"                                                00780000
  79. If fm = "" Then fm = "*"                                                00790000
  80. If ft = "GOPHER" | ft = "GOPLINK" Then Do                               00800000
  81.     /*  read gopher link information  */                                00810000
  82.     'CALLPIPE <' fn ft fm '| GOPSRVGL | *:'                             00820000
  83.     Return                                                              00830000
  84.     End                                                                 00840000
  85.                                                                         00850000
  86. /*  this is for Yossie:  hide filemode zero  */                         00860000
  87. If Length(fm) > 1 Then If Substr(fm,2,1) = '0' Then Return              00870000
  88.                                                                         00880000
  89. fp = Strip(fp)                                                          00890000
  90. If fp = "" Then Do                                                      00900000
  91.     If  Index(fn ft, '*') > 0   | ,                                     00910000
  92.         ft = "FILELIST"         Then fp = Translate(fn,lc,uc)           00920000
  93.     Else  fp = Translate(fn||'.'||ft,lc,uc)                             00930000
  94.     End  /*  If  ..  Do  */                                             00940000
  95.                                                                         00950000
  96. If name = "" Then name = fp     /*  default name is relative path  */   00960000
  97. fp = Translate(fp,"%","/")        /*  no slashes in partial path!  */   00970000
  98. If type = "" Then type = gtype(ft)                                      00980000
  99. host = localhost                                                        00990000
  100. port = localport                                                        01000000
  101. path = type || localpath || '/' || fp                                   01010000
  102.                                                                         01020000
  103. /* read overrides from the NAMES file, if any */                        01030000
  104. If menu ^= "" Then Call GOVER                                           01040000
  105.                                                                         01050000
  106. 'OUTPUT' type || name || '05'x || ,                                     01060000
  107.       /* type */ path || '05'x || ,                                     01070000
  108.                  host || '05'x || port                                  01080000
  109.                                                                         01090000
  110. Return                                                                  01100000
  111.                                                                         01110000
  112.                                                                         01120000
  113.                                                                         01130000
  114. /* -------------------------------------------------------------- PREFAB01140000
  115.  *  Preceeding stage has supplied some of the parameters.  (thank you)  01150000
  116.  */                                                                     01160000
  117. PREFAB:                                                                 01170000
  118.                                                                         01180000
  119. Parse Var record name '05'x path '05'x host '05'x port '05'x rest       01190000
  120. Parse Var path 1 type 2 path                                            01200000
  121. path = type || localpath || '/' || path                                 01210000
  122. If host = "" Then host = localhost                                      01220000
  123. If port = "" Then port = localport                                      01230000
  124. 'OUTPUT' name || '05'x || path || '05'x || ,                            01240000
  125.          host || '05'x || port || '05'x || rest                         01250000
  126. Return                                                                  01260000
  127.                                                                         01270000
  128.                                                                         01280000
  129.                                                                         01290000
  130. /* --------------------------------------------------------------- GOVER01300000
  131.  *  Read the specified NAMES file for menu data overrides, if any.      01310000
  132.  */                                                                     01320000
  133. GOVER:                                                                  01330000
  134.                                                                         01340000
  135. Address "COMMAND" 'STATE' menu 'NAMES *'                                01350000
  136. If rc ^= 0 Then Return                                                  01360000
  137.                                                                         01370000
  138. 'CALLPIPE COMMAND NAMEFIND :NICK' fp ,                                  01380000
  139.         ':TYPE :NAME :PATH :HOST :PORT (FILE' menu ,                    01390000
  140.         '| VAR _TYPE | DROP | VAR _NAME | DROP | VAR _PATH | DROP' ,    01400000
  141.         '| VAR _HOST | DROP | VAR _PORT'                                01410000
  142. If rc ^= 0 Then                                                         01420000
  143. 'CALLPIPE COMMAND NAMEFIND :FN' fn ':FT' ft ,                           01430000
  144.         ':TYPE :NAME :PATH :HOST :PORT (FILE' menu ,                    01440000
  145.         '| VAR _TYPE | DROP | VAR _NAME | DROP | VAR _PATH | DROP' ,    01450000
  146.         '| VAR _HOST | DROP | VAR _PORT'                                01460000
  147. If rc ^= 0 Then Return                                                  01470000
  148.                                                                         01480000
  149. /*      defaults for  type, name, path, host, port    *                 01490000
  150.  *      are supplied by the calling routine           */                01500000
  151.                                                                         01510000
  152. If _host ^= "" Then host = _host                                        01520000
  153. If _port ^= "" Then port = _port                                        01530000
  154. If _path ^= "" Then path = _path                                        01540000
  155. If _name ^= "" Then name = _name                                        01550000
  156. If _type ^= "" Then type = _type                                        01560000
  157.                                                                         01570000
  158. Select                                                                  01580000
  159.     When _host ^= "" & _port = "" Then port = 70                        01590000
  160.     When _host = "" & _port ^= "" Then host = localhost                 01600000
  161.     Otherwise nop                                                       01610000
  162.     End  /*  When  Select  */                                           01620000
  163.                                                                         01630000
  164. If _host ^= "" | _port ^= "" Then Do                                    01640000
  165.     path = _path                                                        01650000
  166.     type = _type                                                        01660000
  167.     If type = "" Then type = "1"                                        01670000
  168.     End  /*  If  ..  Do  */                                             01680000
  169. Else If _type ^= "" & _path = "" Then                                   01690000
  170.     path = _type || localpath || '/' || fp                              01700000
  171.                                                                         01710000
  172. Return                                                                  01720000
  173.                                                                         01730000
  174.                                                                         01740000
  175.                                                                         01750000
  176. /* --------------------------------------------------------------- GTYPE01760000
  177.  * Returns the default Gopher type character for CMS filetype specified.01770000
  178.  */                                                                     01780000
  179. GTYPE:    Procedure                                                     01790000
  180. Parse Arg ft                                                            01800000
  181. Select  /*  ft  */                                                      01810000
  182.     When ft = "*"        Then Return '1'                                01820000
  183.     When ft = "-"        Then Return '1'                                01830000
  184.     When ft = ""         Then Return '1'                                01840000
  185.     When ft = "FILELIST" Then Return '1'                                01850000
  186.     When ft = "GOPHER"   Then Return '1'                                01860000
  187. /*  When ft = "CSO"      Then Return '2'  */                            01870000
  188. /*  When ft = ?          Then Return '3'  */                            01880000
  189. /*  When ft = "MAC"      Then Return '4'  */                            01890000
  190. /*  When ft = "DOS"      Then Return '5'  */                            01900000
  191.     When ft = "UUE"      Then Return '6'                                01910000
  192. /*  When ft = "SEARCH"   Then Return '7'  */                            01920000
  193. /*  When ft = "TELNET"   Then Return '8'  */                            01930000
  194.     When ft = "TXT"      Then Return '0'    /*  plain text  */          01940000
  195.     When ft = "TEXT"     Then Return '9'    /*  deck; not plain text  */01950000
  196.     When ft = "TXTLIB"   Then Return '9'                                01960000
  197.     When Left(ft,3) = "TXT" Then Return '9'                             01970000
  198.     When ft = "CARDDUMP" Then Return '9'                                01980000
  199.     When ft = "TAR"      Then Return '9'                                01990000
  200.     When ft = "EXE"      Then Return '9'                                02000000
  201.     When ft = "DVI"      Then Return '9'                                02010000
  202.     When ft = "TFM"      Then Return '9'                                02020000
  203.     When ft = "FMT"      Then Return '9'                                02030000
  204.     When ft = "ADMGDF"   Then Return '9'                                02040000
  205.     When ft = "ADMSYMBL" Then Return '9'                                02050000
  206.     When ft = "SASUSER"  Then Return '9'                                02060000
  207.     When ft = "SAS6USER" Then Return '9'                                02070000
  208.     When ft = "SND"      Then Return 's'                                02080000
  209. /*  When ft = "EPS"      Then Return 'p'  */                            02090000
  210. /*  When ft = "PS"       Then Return 'p'  */                            02100000
  211.     When ft = "MODULE"   Then Return 'v'                                02110000
  212.     When ft = "LOADLIB"  Then Return 'v'                                02120000
  213.     When ft = "XRX"      Then Return 'v'                                02130000
  214.     When ft = "GIF"      Then Return 'I'                                02140000
  215.     Otherwise                 Return '0'                                02150000
  216.     End  /*  Select  ft  */                                             02160000
  217.                                                                         02170000
  218.